package com.alks.entity.data.enums;

import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

@Getter
public enum SlipTypeEnum {
    SLIP_ODN("普通开补","1"),
    SLIP_VAMP("鞋面全套","2"),
    SLIP_MOD("成型全套","3"),
    SLIP_MTR("原材料开补","4");

    private final String slipName;
    private final String slipType;



    SlipTypeEnum (String slipName, String slipType) {
        this.slipName=slipName;
        this.slipType=slipType;
    }

    /**
     * 根据补料类型ID找补料方法名称
     * @param slipName 补料方法ID
     * @return 补料方法名称
     */
    public static String SlipTypeFind(String slipName) {
        for (SlipTypeEnum slipTypeEnum : SlipTypeEnum.values()) {
            if (slipTypeEnum.slipName.equals(slipName)) {
                return slipTypeEnum.slipType;
            }
        }
        return null;
    }

    /**
     * 根据补料方法名称找补料类型ID
     * @param slipType 补料方法名称
     * @return 补料类型ID
     */
    public static String SlipNameFind(String slipType) {
        for (SlipTypeEnum slipTypeEnum : SlipTypeEnum.values()) {
            if (slipTypeEnum.slipType.equals(slipType)) {
                return slipTypeEnum.slipName;
            }
        }
        return null;
    }

    /**
     * 遍历补料类型
     * @return 补料类型ID集合
     */
    public static List<String> SlipNameList(){
        List<String> slipName=new ArrayList<>();
        for (SlipTypeEnum slipTypeEnum : SlipTypeEnum.values()) {
            slipName.add(slipTypeEnum.getSlipName());
        }
        return slipName;
    }

    /**
     * 判断给定的slipType是否存在于枚举中
     * @param slipType 要检查的补料类型ID
     * @return slipType，否则返回false
     */
    public static boolean isSlipTypeExist(String slipType) {
        for (SlipTypeEnum v : values()) {
            if (v.getSlipType().equals(slipType)) {
                return true;
            }
        }
        return false;
    }
}
